home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
batchut
/
ranarg.zip
/
RANDARG.DOC
< prev
next >
Wrap
Text File
|
1987-03-15
|
3KB
|
88 lines
RANDARG.DOC 15 March 87 Page 1
Copyright 1987 Michael M Rubenstein
This software may be freely distributed provided no fee is
assessed.
Description.
RANDARG randomly selects an argument or a line from a file and
either executes it or echoes it to stdout. It can be used to
randomly produce messages or commands in a batch file.
Usage.
To randomly select an argument, simply execute RANDARG with the
desired arguments. Arguments containing spaces or tabs must be
enclosed in quotes or appostrophies. For example, the command
randarg "Syntax error -- reenter" "You goofed"
will write one of the two messages to stdout.
If the -c option is given, the argument selected will be
executed. For example, if you have a program TUNE which
generates one of 3 tunes depending on the argument, the command
randarg -c "tune 1" "tune 2" "tune 3"
will select the tune randomly.
If the argument selected is empty, no operation is performed.
Wild card expansion of file names may be used (though I haven't
found any real use for it). Arguments included in quotes or
appostrophes are not expanded.
If the -f option is given, selection is from a file rather than
from the command line. The first line of the file must contain
the number of remaining lines in the file. A random line after
line 1 is selected. For example, the command
randarg -f errmsg
with the file ERRMSG containing
2
Syntax error -- reenter
You goofed
is equivalent to the first example.
The -f option may be combined with -c. The command
RANDARG.DOC 15 March 87 Page 2
randarg -fc tunecmd
with the file TUNECMD containing
3
tune 1
tune 2
tune 3
is equivalent to the second example.
The algorithm used is not suitable for very large files since it
reads the file sequentially to get the line selected. If the
first line of the file does not contain the number of lines, the
number is 0, or if there are not enough lines in the file,
RANDARG exits without comment.
For the Hacker.
RANDARG is written in AZTEC C with a modified run time system.
The run time system handles expansion of wildcards and quoted
arguments. The code is very standard and there should be little
difficulty in porting to other versions of C.